package com.chixing.xxl;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class xin {

    @XxlJob("sendMessage")
    public ReturnT<String> sendMessage(String param) {
        // 获取分片参数的新方式
        XxlJobContext xxlJobContext = XxlJobContext.getXxlJobContext();
        int shardIndex = xxlJobContext.getShardIndex();
        int shardTotal = xxlJobContext.getShardTotal();

        log.info("xxl-job-executor-index:{},total:{}", shardIndex, shardTotal);
        log.info("xxl-job-executor-param:{}", param);
        return ReturnT.SUCCESS;
    }

    @XxlJob(value = "testJob")
    public void testJobOne() {
        System.out.println("-----这是 testJob 测试任务-----");
        System.out.println(">>>>>>>>>>>>> testJobOne 执行成功 >>>>>>>>>>>>>");
    }
}

